<?php
class Manage_spots extends CI_Model {

    function __construct(){
        parent::__construct();
    }


    function addSpot($data) {
        $insert = $this->mongo_db->insert('user_spots', $data);
        return $insert;
    }
    function getSpotID($id){
        $this->mongo_db->where(array('_id'=>new MongoId ($id)));
        $query = $this->mongo_db->get('user_spots');
        return $query;
    }
    function checkExists($id){
        $this->mongo_db->where('_id' , new MongoId ($id));
        $query = $this->mongo_db->get('user_spots');
        return count($query);
    }
    function updatePictureSpot($id,$identifier,$image){

        $this->mongo_db->where(array('_id'=>new MongoId ($id)))->push($identifier, $image)->update('user_spots');

    }
    function getSpotsByRegions($region){
        $this->mongo_db->where('region' ,$region);
        $this->mongo_db->select(array('name', '_id'));
        $query = $this->mongo_db->get('user_spots');
        return $query;
    }
    function getSpotInfos($spotID){
        $this->mongo_db->where('_id' , new MongoId ($spotID));
        $query = $this->mongo_db->get('user_spots');
        return $query;
    }
}
?>
